DEF_PROJECT=../../..
include $(DEF_PROJECT)/scripts/main.mk
name=vim
version=7.3
srctree=$(name)$(subst .,,$(version))
prefix=/usr
destdir=$(DIR_SYSROOT)
deps=ncurses
extdeps=eglibc-tools gcc-tools binutils-tools linux-header-tools
patch=vim-7.3-update.patch

DL_SERV=ftp
DL_HOST=ftp.vim.org
DL_PATH=pub/$(name)/unix
DL_SUFFIX=tar.bz2

cdefs+=CPPFLAGS="-DUNUSED="

CFLAGS+=-I$(destdir)/usr/include
LDFLAGS+=-L$(destdir)/usr/lib

cflags+=--host=$(CC_TARGET)
cflags+=--build=$(CC_HOST)
cflags+=--enable-multibyte
cflags+=--enable-gui=no
cflags+=--disable-gtktest
cflags+=--disable-xim
cflags+=--with-features=normal
cflags+=--disable-gpm
cflags+=--without-x
cflags+=--disable-netbeans
cflags+=--with-tlib=ncurses
cflags+=--cache-file=$(DEF_CACHE)

pre-build:
	echo vim_cv_getcwd_broken=no >$(source)/src/auto/$(DEF_CACHE)
	echo vim_cv_memmove_handles_overlap=yes >>$(source)/src/auto/$(DEF_CACHE)
	echo vim_cv_stat_ignores_slash=no >>$(source)/src/auto/$(DEF_CACHE)
	echo vim_cv_terminfo=yes >>$(source)/src/auto/$(DEF_CACHE)
	echo vim_cv_tgent=zero >>$(source)/src/auto/$(DEF_CACHE)
	echo vim_cv_toupper_broken=no >>$(source)/src/auto/$(DEF_CACHE)
	echo vim_cv_tty_group=world >>$(source)/src/auto/$(DEF_CACHE)
	echo ac_cv_sizeof_int=4 >>$(source)/src/auto/$(DEF_CACHE)
	echo '#define SYS_VIMRC_FILE "/etc/vimrc"' >>$(source)/src/feature.h
	cd $<;$(cdefs) ./configure $(cflags)
	sed -e '/tgetent/d' -e '/tgoto/d' -e '/tputs/d' -i $(source)/src/osdef2.h.in

post-build:
	$(MAKE) -C $(if $(build),$(build),$(source)) $(iflags)
	ln -sf vim $(destdir)/usr/bin/vi
	cp $(DIR_ORIG)/vimrc $(destdir)/etc/
